
#ifndef __AES_SYMM_KEY_H
#define __AES_SYMM_KEY_H

#include "keys.h"

// This cheats slightly, using the base64 'key' simply as a password and expecting the hash to be good!

#define INITIALISATION_VECTOR "\x24\x3f\x6a\x88\x85\xa3\x08\xd3\x13\x19\x8a\x2e\x03\x70\x73\x44"

class AESSymmKey : public EncryptionKey, public DecryptionKey, public SymmKey
{
   public:
      AESSymmKey();
      AESSymmKey(const char *name);
      // Generate new AES key
      AESSymmKey(int bits, const char *name);
      // Copy AES key
      AESSymmKey(const AESSymmKey &other);
      // Burn and free password
      ~AESSymmKey();
      // Get context
      int GetCryptlibContext(CRYPT_CONTEXT *keyContext);
      // Get encryption context
      int GetCryptlibEncryptionContext(CRYPT_CONTEXT *keyContext);
      // Get decryption context
      int GetCryptlibDecryptionContext(CRYPT_CONTEXT *keyContext);
      // To import from text - Base64 RAW or PEM
      int ImportKeyFromASCII(const char *text, const char *name);
      // To export to text - Base64 RAW or PEM
      int ExportKeyToASCII(char **text);
      // Import from text with password
      int ImportKeyFromASCIIWithPassword(const char *text, const char *password, const char *name);
      // Export to text with password
      int ExportKeyToASCIIWithPassword(char **text, const char *password);
      // Compare key equal
      int CompareKeyEqual(SymmKey *symkey);
      // Get key type
      int GetKeyType() { return KEY_TYPE_SYMM_AES; }
   private:
      char *keypassword;
};

#endif
